class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-09-01",
      revision: "688d5586567f748b7985615b4d1f829c0415e1b7"
  version "2021-09-01"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "6ae09dc93c2ce6ada9f08e26b8246b529c2354528a6a159efe9abbbd05dc3f44"
    sha256 cellar: :any_skip_relocation, big_sur:       "53bb547542cba940543e246a40a89c2023c5a20bc2c378f277666fc8095dd04f"
    sha256 cellar: :any_skip_relocation, catalina:      "72c1aedb8fac18501de916a8616e435c5f30481b9b3b8e23e50a3fc2ccb9c54c"
    sha256 cellar: :any_skip_relocation, mojave:        "0f96fac29a5ccae2e2a23040192258e4a668adf3054a11a1811960516ceaa084"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "4e5d7c79cece2ec77a74a7cf6c4eb7a36b2e2fd386a03b14580c255ccad619f7"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
